# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=requests-kerberos
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.14.0
pkgrel=5
pkgdesc="A kerberos of useful classes and functions to be used with python-requests (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://github.com/requests/requests-kerberos'
license=('Apache')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-cryptography"
         "${MINGW_PACKAGE_PREFIX}-python-requests"
         "${MINGW_PACKAGE_PREFIX}-python-winkerberos"
         "${MINGW_PACKAGE_PREFIX}-python-pyspnego")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-mock")
options=('staticlibs' 'strip' '!debug')
source=("${_realname}-${pkgver}.tar.gz::https://github.com/requests/requests-kerberos/archive/v${pkgver}.tar.gz")
sha512sums=('9dd6eed0d6afe4b852ba96f621be3af2965e9011bf372c5dce77e0bca18191255ea407ba313904271615d722d60029807db2d6815b24437b021b02b026eb60d6')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/${_realname}-${pkgver}"
  MSYSTEM= ${MINGW_PREFIX}/bin/python -m pytest
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
